<template>
  <div class="one">
    <el-table
      :data="loginList.slice((currentPage-1)*pagesize,currentPage*pagesize)"
      style="width: 100%;" >
      <el-table-column  prop="id"  label="编号"  width="180">
      </el-table-column>
      <el-table-column  prop="loginName" label="管理员名"width="180">
      </el-table-column> 
      <el-table-column prop="loginDate" label="登录日期" align="center">
      </el-table-column>
       <el-table-column prop="loginNumber" label="登录次数" align="center">
      </el-table-column>
        <el-table-column  label="操作" align="center">
          <template slot-scope="scops">
           <el-button type="primary" size="mini" icon="el-icon-delete" @click="Deletelog(scops.row.id)">删除</el-button>
          </template>
      </el-table-column>
    </el-table>
      <!-- 分页 -->
									  <el-pagination style="margin-top:20px ;"
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page="currentPage"
                            :page-sizes="[5, 8]" 
                            :page-size="pagesize"        
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="loginList.length">    
                    </el-pagination>

  </div>
</template>

<script>
export default {
  name:'loginLog',
  data(){
    return{
       currentPage:1, //初始页
       pagesize:8,    //    每页的数据
    loginList:[{
    id:'',
    loginName:'',
    loginDate:'',
    loginNumber:''
  }]
}
}
,mounted(){
this.getLogData()
},
methods:{
  getLogData:function(){
    this.$axios.get("/log/loginLog").then(res=>{
      this.loginList=res.data;
      console.log(this.loginList)
    })
  },
  Deletelog:function(id){
    this.$axios.get("/log/deleteLog",{params:{id:id}}).then(res=>{
      alert(res.data);
      this.getLogData()
    })
  },
  	//分页
		handleSizeChange: function (size) {
                this.pagesize = size;
                console.log(this.pagesize)  //每页下拉显示数据
        },
    handleCurrentChange: function(currentPage){
                this.currentPage = currentPage;
                console.log(this.currentPage)  //点击第几页
        },
    handleUserList() {
            this.$axios.get('http://localhost:8080/BMS/product/getproducts').then(res => {  //这是从本地请求的数据接口，
                this.userList = res.body
            })
        }
}

}
</script>

<style  scoped>
.one{
  
}
</style>